<template>
	<view class="content">
		<view style="height: 170rpx;background-color: #1262DB;">
			<view style="height: 40rpx;"></view>
			<view class="wid90 mar bacFFF borRad10">
				<uni-datetime-picker v-model="datetimerange" type="daterange" rangeSeparator="至" @change="changeTime" />
			</view>
		</view>
		<view class="wid90 mar mar-top30 dis disAl disJuB" style="height: 200rpx;">
			<view class="textCen" style="">
				<view class="dis disAl disJuC wh foSi30 borRad40" @click="chengType(0)" 
				:style="clickTrue == 0?'background-color: #1262DB;color: #fff;':''">总押金</view>
				<view class="mar-top30 foSi40" :style="clickTrue == 0?'color: #1262DB;':'color: #AEACAC;'">¥0.00</view>
			</view>
			<view class="textCen" style="">
				<view class="dis disAl disJuC wh foSi30 borRad40" @click="chengType(1)" 
				:style="clickTrue == 1?'background-color: #1262DB;color: #fff;':''">试剂押金</view>
				<view class="mar-top30 foSi40" :style="clickTrue == 1?'color: #1262DB;':'color: #AEACAC;'">¥0.00</view>
			</view>
			<view class="textCen" style="">
				<view class="dis disAl disJuC wh foSi30 borRad40" @click="chengType(2)" 
				:style="clickTrue == 2?'background-color: #1262DB;color: #fff;':''">仪器押金</view>
				<view class="mar-top30 foSi40" :style="clickTrue == 2?'color: #1262DB;':'color: #AEACAC;'">¥0.00</view>
			</view>
		</view>
		<view class="xhx"></view>
		<view style="height: 100rpx;" class="wid90 mar dis disAl disJuB">
			<view class="foSi40" style="padding-left: 10rpx;border-left: 6rpx solid #1262DB;font-weight: 600;">钱包明细</view>
			<view @click="tiaozhuan('/pages/wallet/withdrawDeposit?tx=1')" 
			class="dis disAl disJuC borRad10 coFFF" style="width: 120rpx;height: 56rpx;background-color: #1262DB;">提现</view>
		</view>
		<scroll-view style="height: calc(100vh - 500rpx);" scroll-y="true" class="scroll-Y" @scrolltolower="lower">
			<view v-if="list.length == 0" class="wh100 dis disAl disJuC">
				<image src="../../static/incomeDetail/wushiju.png" style="width: 197rpx;height: 226rpx;"></image>
			</view>
			<view v-if="list.length != 0" class="foSi30 mar-top20"
				v-for="(item,index) in list" :key="index">
				<view class="wid90 mar hei60 dis disAl disJuB">
					<view>{{item.createtime}}</view>
					<view style="color: #2088f8;">返还金额：￥{{item.money}}</view>
				</view>
				<view class="wid90 mar mar-top10" style="font-weight: 600;">订单编号：{{item.oid}}</view>
				<view class="wid90 mar mar-top10" style="color: #AEACAC;">{{item.notes}}</view>
				<view style="height: 20rpx;"></view>
				<view class="xhx"></view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				clickTrue: 0,
				type: 2,
				list: [],
				datetimerange: [],
				page: 0,
				total_revenue:'',
				last_page: 0
			}
		},
		onLoad() {
			this.dangqian()
		},
		methods: {
			dangqian(){
				this.zhanshi = 0
				var date = new Date()
				var year = date.getFullYear()
				var month = date.getMonth() + 1
				var day = date.getDate()
				this.datetimerange = [year+'-'+month+'-'+day,year+'-'+month+'-'+day]
				this.getuserinfo()
			},
			chengType(index){
				this.clickTrue = index
				this.page = 0
				this.getuserinfo()
			},
			changeTime(e) {
				this.datetimerange = e;
				this.page = 0
				this.getuserinfo()
			},
			getuserinfo(){
				var that = this
				uni.request({
				    url: that.global.url + 'api/order/revenue_details',
				    method: "POST",
					header: {
						'token': uni.getStorageSync('token')
					},
				    data: {
						begintime: this.datetimerange[0],
						endtime: this.datetimerange[1],
						page: this.page,
						type: this.type
					},
				    success(res) {
				        let result = res.data
				        if(result.code == 1){
							if(that.page == 0){
								that.list = result.data.data.data
							}else{
								that.list = that.list.concat(result.data.data.data)
							}
							that.last_page = result.data.data.last_page
							that.total_revenue = result.data.total_revenue
							that.total_revenue = result.data.total_revenue
							that.total_revenue = result.data.total_revenue
						}else{
				           uni.showToast({
				           	title: result.msg,
				           	icon: 'error'
				           })
				        }
				       
				    }
				})
			},
			lower: function(e) {
				if(this.last_page != this.page+1){
					this.page++
					this.getuserinfo()
				}
			},
			tiaozhuan(url){
				uni.navigateTo({
					url: url
				});
			},
		}
	}
</script>

<style>
	.content {}
	.uni-date-x--border {
		height: 90rpx;
	}
	.wh{
		width: 190rpx;
		height: 76rpx;
		border: 1rpx solid #AEACAC;
		color: #AEACAC;
	}
</style>
